//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Drawing;
using OpenLS.Vml.Presentation;
using OpenLS.Vml.Spreadsheet;
using OpenLS.Vml.Word;

namespace OpenLS.Vml
{
    public abstract class ShapeElement : IOfficeXmlSerializable
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            ReadXmlCore(context);
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            WriteXmlCore(context);
        }

        #endregion

        internal static ShapeElement ReadShapeElement(ReadContext context)
        {
            switch (context.ReaderLocalName)
            {
                case null:
                    return null;
                case Path.xmlName:
                    return context.ReadElement<Path>();
                case Formulas.xmlName:
                    return context.ReadElement<Formulas>();
                case "handles":
                    return context.ReadElement<Handles>();
                case Fill.xmlName:
                    return context.ReadElement<Fill>();
                case Stroke.xmlName:
                    return context.ReadElement<Stroke>();
                case Shadow.xmlName:
                    return context.ReadElement<Shadow>();
                case TextBox.xmlName:
                    return context.ReadElement<TextBox>();
                case "textpath":
                    return context.ReadElement<TextPath>();
                case ImageData.xmlName:
                    return context.ReadElement<ImageData>();

                case "skew":
                    return context.ReadElement<Skew>();
                    ;
                case "extrusion":
                    return context.ReadElement<Extrusion>();
                case "callout":
                    return context.ReadElement<Callout>();
                case Lock.xmlName:
                    return context.ReadElement<Lock>();
                case "clippath":
                    return context.ReadElement<ClipPath>();
                case "signatureline":
                    return context.ReadElement<SignatureLine>();

                case "wrap":
                    return context.ReadElement<Wrap>();
                case "anchorlock":
                    return context.ReadElement<AnchorLock>();
                case "complex":
                    return context.ReadElement<Complex>();

                case "bordertop":
                    return context.ReadElement<BorderTop>();
                case "borderbottom":
                    return context.ReadElement<BorderBottom>();
                case "borderleft":
                    return context.ReadElement<BorderLeft>();
                case "borderright":
                    return context.ReadElement<BorderRight>();
                case ClientData.xmlName:
                    return context.ReadElement<ClientData>();
                case "textdata":
                    return context.ReadElement<TextData>();
                case ShapeLayout.xmlName:
                    throw new NotImplementedException();
                case "ink":
                    return context.ReadElement<Ink>();
                case IsComment.xmlName:
                    return context.ReadElement<IsComment>();
                case ReColorInfo.xmlName:
                    return context.ReadElement<ReColorInfo>();
                case PowerpointTag.xmlName:
                    return context.ReadElement<PowerpointTag>();
                default:
                    throw new NotSupportedException(context.ReaderLocalName);
            }
        }

        internal abstract void ReadXmlCore(ReadContext context);

        internal abstract void WriteXmlCore(WriteContext context);
    }
}